home *** CD-ROM | disk | FTP | other *** search
- #
- # Convert a header to a function
- #
- # $VER: hdr2func V1.01 (25.05.1993)
- #
-
- # Remember position
- push pos
-
- # Find RETURN. To be more save, we look for NAME first
- findstr NAME prev find RETURN down scanf %[~;]
-
- # Look for the beginning of the function-body
- find */ find {
- # move to the decl. line
- up
- # clear this line
- if c<>32 deline insline
-
- # insert "return"
- ($scanf)
- # check the last part. If it's not "void", remove it
- last wleft if x<>1 `if c<>"void" remeol'
-
- # get name of function
- findstr NAME prev down scanf w
- # and copy it
- find */ find { up last right ($scanf)
-
- # search parameters
- findstr PARAMETER prev down
- # remember old block and begin to mark new one
- push block block
- # find the column we begin in
- firstnb set column $colno
- # as long as there is no empty line, do down
- while x>=$column `down firstnb'
- # we are one line too deep now
- up
- # end block
- block
- # copy block to function-head. Remember the position of the first line of
- # the block
- find */
- find {
- push pos
- bcopy
-
- # goto begining of line
- peek auto
- first
- # remove comments
- while c<>"{" (firstnb scanf %[~;] remeol first (\$scanf) down first)
- # go up
- pop auto
- # replace all ';' by ',' and join things together until we find a '{'
- while c<>"{" `last `,' join last left'
-
- # get rid of '{' and the last ','
- split last bs
- # add a '(' after the name of the function, join the args and add a ')' at the
- # end
- up last right `(' join del last `)'
- # remove all obsolete blanks
- unjustify
- # pop block & position
- pop auto
- pop auto
-